﻿@using Gx.Model.ViewModel;
@{
    ViewBag.Title = "LKBillTemplateIndex";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
@model LKBillTemplateDto
<link href="~/Content/css/custome.css" rel="stylesheet" />
<div title="单据模板" style="width:auto; height:auto; padding-left:5px; font-size:14px;  ">
    <div class="ftitle">
        <span>单据类型</span>
        <select id="billtype" class="easyui-combobox" name="language" style="width:200px;" data-options="onChange:changeBillType,editable:false">
            <option value="1">零仓合同</option>
            <option value="2">包仓合同</option>
            @*<option value="3">商品入库单</option>
                <option value="4">商品出库单</option>
                <option value="5">商品调仓单</option>
                <option value="6">商品转卡单</option>*@
        </select>
        <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="saveData()">保存</a>
    </div>
    <form id="fm" method="post" novalidate>
        <div id="tempcontext">

        </div>

    </form>
    @*<div id="customerselecttoolbar2">
        <input id="SelectCustomerText2" class="easyui-textbox " style="width: 173px; height: 30px;" />
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="querycustomer2()">查询</a>
    </div>*@
</div>
<script src="~/Js/Global.js"></script>
<script type="text/javascript">
    $(function () {

        $.post("/BasicManage/_LKZeroWarehouseContractTemplate", null, function (html) {
            $("#tempcontext").append(html);
            $.parser.parse($("#tempcontext"));
            InitChargingUnitCombobox();
            InitColdAlgorithmCombobox();
            //InitCustomer();
        });

    });
    var StoreType =@Model.LKWarehouseContract.StoreType;
    var StoreAlgorithm =@Model.LKWarehouseContract.StoreAlgorithm;
    function saveData() {

        var url;
        var billtype = $('#billtype').combobox('getValue');
        if (billtype == 1) {
            url = "/BasicManage/SaveLKZeroWarehouseContractTemplate";
            $("#hidIsByTon").val($('#sbIsByTon').switchbutton('options').checked);
        }
        else if (billtype == 2) {
            url = "/BasicManage/SaveLKWarehouseContractTemplate";
            $("#hidIsByTon").val($('#sbIsByTon').switchbutton('options').checked);
        }
        //else if (billtype == 3) {
        //    url = "/BasicManage/SaveLKWarehouseEntryTemplate";
        //}
        //else if (billtype == 4) {
        //    url = "/BasicManage/SaveLKWarehouseOutTemplate";
        //}
        //else if (billtype == 5) {
        //    url = "/BasicManage/SaveLKWarehouseAdjustTemplate";
        //}
        //else if (billtype == 6) {
        //    url = "/BasicManage/SaveLKTransferTemplate";
        //}
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (json) {
                var json = eval('(' + json + ')');
                Helper.Show(json.Msg);
                if (json.Success) {
                    //$('#fm').form('clear');
                    if (billtype == 2) {
                        StoreAlgorithm = json.Result.StoreAlgorithm;
                        StoreType=json.Result.StoreType;
                    }
                }
            }
        });
    }
    function changeBillType() {
        var billtype = $('#billtype').combobox('getValue');
        $("#tempcontext").empty();
        if (billtype == 1) {

            $.post("/BasicManage/_LKZeroWarehouseContractTemplate", null, function (html) {
                $("#tempcontext").append(html);
                $.parser.parse($("#tempcontext"));
                InitChargingUnitCombobox();
                InitColdAlgorithmCombobox();
                //InitCustomer();
            });
        }
        else if (billtype == 2) {
            $.post("/BasicManage/_LKWarehouseContractTemplate", null, function (html) {
                $("#tempcontext").append(html);
                $.parser.parse($("#tempcontext"));
                InitStoreTypeCombobox();
                InitStoreAlgorithmCombobox();
                //InitCustomer();
                InitWareHouse();
                $('#StoreType').combobox('setValue', StoreType);
                $('#StoreAlgorithm').combobox('setValue', StoreAlgorithm);
            });
        }
        //else if (billtype == 3) {
        //    $.post("/BasicManage/_LKWarehouseEntryTemplate", null, function (html) {
        //        $("#tempcontext").append(html);
        //        $.parser.parse($("#tempcontext"));
        //        InitCustomer();
        //    });
        //}
        //else if (billtype == 4) {
        //    $.post("/BasicManage/_LKWarehouseOutTemplate", null, function (html) {
        //        $("#tempcontext").append(html);
        //        $.parser.parse($("#tempcontext"));
        //        InitCustomer();
        //    });
        //}
        //else if (billtype == 5) {
        //    $.post("/BasicManage/_LKWarehouseAdjustTemplate", null, function (html) {
        //        $("#tempcontext").append(html);
        //        $.parser.parse($("#tempcontext"));
        //        InitCustomer();
        //    });
        //}
        //else if (billtype == 6) {
        //    $.post("/BasicManage/_LKTransferTemplate", null, function (html) {
        //        $("#tempcontext").append(html);
        //        $.parser.parse($("#tempcontext"));
        //        InitChargingUnitCombobox();
        //        InitColdAlgorithmCombobox();
        //        InitCustomerById(InCustomerId, customerselecttoolbar2);
        //        InitCustomerById(OutCustomerId, customerselecttoolbar2);
        //    });
        //}
    }

</script>

